package com.hulk.dryad.manage.boot.basic.init;

import net.dreamlu.mica.core.utils.Once;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * 只执行一次的 ApplicationContextInitializer
 *
 * @author hulk
 */
public abstract class AbstractOnceInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
	private final Once once = new Once();

	@Override
	public void initialize(ConfigurableApplicationContext context) {
		once.run(this::run, context);
	}

	/**
	 * 执行
	 *
	 * @param context context
	 */
	public abstract void run(ConfigurableApplicationContext context);

}
